
#!coding:utf-8
# vim: tabstop=4 shiftwidth=4 softtabstop=4
"""
    @author jay.han
"""

FAKE_DOM ="""<domain type="kvm">
  <uuid>12312312312312313</uuid>
  <name>i-00000001</name>
  <memory>1048576</memory>
  <vcpu>1</vcpu>
  <sysinfo type="smbios">
    <bios>
      <entry name="vendor">morningcloud</entry>
      <entry name="version">1.0</entry>
    </bios>
    <system>
      <entry name="manufacturer">Tcloud</entry>
      <entry name="product">2.2</entry>
      <entry name="version">2.2</entry>
      <entry name="serial">2.2</entry>
      <entry name="uuid">12312312312312313</entry>
    </system>
  </sysinfo>
  <os>
    <type>hvm</type>
    <boot dev="hd"/>
    <smbios mode="sysinfo"/>
  </os>
  <clock offset="localtime"/>
  <cpu match="exact"/>
  <devices>
    <disk type="file" device="disk">
      <driver name="qemu" type="qcow2"/>
      <source file="/home/ezzze/instances/i-0000001/disk"/>
      <target bus="virtio" dev="vda"/>
    </disk>
    <input type="tablet" bus="usb"/>
    <input type="mouse" bus="ps2"/>
    <interface type="bridge">
      <mac address="123123"/>
      <model type="virtio"/>
      <source bridge="br0"/>
    </interface>
    <graphics type="vnc" autoport="no" listen="0.0.0.0" port="5900"/>
    <sound model="ac97"/>
  </devices>
</domain>
"""
DISK_XML ="""
<domain type='kvm'>
  <name>i-00000060</name>
  <uuid>5b6fc11b-5ba2-445c-aa87-05142d6ca58b</uuid>
  <memory unit='KiB'>1048576</memory>
  <currentMemory unit='KiB'>1048576</currentMemory>
  <vcpu placement='static'>1</vcpu>
  <sysinfo type='smbios'>
    <bios>
      <entry name='vendor'>morningcloud</entry>
      <entry name='version'>1.0</entry>
    </bios>
    <system>
      <entry name='manufacturer'>Tcloud</entry>
      <entry name='product'>2.2</entry>
      <entry name='version'>2.2</entry>
      <entry name='serial'>2.2</entry>
      <entry name='uuid'>5b6fc11b-5ba2-445c-aa87-05142d6ca58b</entry>
    </system>
  </sysinfo>
  <os>
    <type arch='x86_64' machine='pc-1.2'>hvm</type>
    <boot dev='cdrom'/>
    <boot dev='hd'/>
    <smbios mode='sysinfo'/>
  </os>
  <features>
    <acpi/>
    <apic/>
  </features>
  <cpu mode='custom' match='exact'>
    <model fallback='allow'>Nehalem</model>
    <vendor>Intel</vendor>
    <feature policy='require' name='rdtscp'/>
    <feature policy='require' name='avx'/>
    <feature policy='require' name='osxsave'/>
    <feature policy='require' name='xsave'/>
    <feature policy='require' name='tsc-deadline'/>
    <feature policy='require' name='pcid'/>
    <feature policy='require' name='pdcm'/>
    <feature policy='require' name='xtpr'/>
    <feature policy='require' name='tm2'/>
    <feature policy='require' name='est'/>
    <feature policy='require' name='vmx'/>
    <feature policy='require' name='ds_cpl'/>
    <feature policy='require' name='monitor'/>
    <feature policy='require' name='dtes64'/>
    <feature policy='require' name='pclmuldq'/>
    <feature policy='require' name='pbe'/>
    <feature policy='require' name='tm'/>
    <feature policy='require' name='ht'/>
    <feature policy='require' name='ss'/>
    <feature policy='require' name='acpi'/>
    <feature policy='require' name='ds'/>
    <feature policy='require' name='vme'/>
  </cpu>
  <clock offset='localtime'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/bin/kvm-spice</emulator>
    <disk type='file' device='floppy'>
      <driver name='qemu' type='raw'/>
      <source file='/etc/thor/virtio-win-1.1.16.vfd'/>
      <target dev='fda' bus='fdc'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/iso/iso/ubuntu-12.04-alternate-i386.iso'/>
      <target dev='hdb' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/home/vmos/instances/i-00000060/disk_2'/>
      <target dev='vdc' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </disk>
    <controller type='usb' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <controller type='fdc' index='0'/>
    <controller type='ide' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <interface type='bridge'>
      <mac address='12:03:fe:54:e7:5b'/>
      <source bridge='br0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <input type='tablet' bus='usb'/>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='5960' autoport='no' listen='0.0.0.0'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>
    <sound model='ac97'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </sound>
    <video>
      <model type='cirrus' vram='9216' heads='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </memballoon>
  </devices>
</domain>
"""

INTERFACE_XML = """
             <interface type='direct'>
              <mac address='52:54:00:d7:4b:43'/>
              <source dev='eth0' mode='vepa'/>
              <model type='virtio'/>
              <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
            </interface>
        """

GUEST_XML =  """
                    <domain xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0" type="kvm">
  <name>i-00000001</name>
  <memory>524288</memory>
  <vcpu>2</vcpu>
  <sysinfo type="smbios">
    <bios>
      <entry name="vendor">morningcloud</entry>
      <entry name="version">1.0</entry>
    </bios>
    <system>
      <entry name="manufacturer">Tcloud</entry>
      <entry name="product">Tcloud</entry>
      <entry name="version">2.2</entry>
      <entry name="serial">123456</entry>
      <entry name="uuid">225555</entry>
    </system>
  </sysinfo>
  <os>
    <type>hvm</type>
    <boot dev="hd"/>
    <boot dev="iso"/>
    <smbios mode="sysinfo"/>
  </os>
  <features>
    <acpi/>
    <apic/>
  </features>
  <clock offset="local"/>
  <cpu mode="host-model" match="exact"/>
  <devices>
    <disk type="file" device="disk">
      <driver name="qemu" type="qcow2" cache="none"/>
      <source file="/home/ezzze/instances/i-00000001/disk"/>
      <target bus="virtio" dev="vda"/>
    </disk>
    <disk type="file" device="cdrom">
      <driver name="qemu" type="raw"/>
      <source file="/home/ezzze/instances/i-00000001/disk"/>
      <target bus="ide" dev="vdc"/>
    </disk>
    <interface type="bridge">
      <mac address="123123"/>
      <model type="virtio"/>
      <source bridge="br0"/>
    </interface>
    <input type="tablet" bus="usb"/>
    <channel type="spicevmc">
      <target type="virtio" name="com.redhat.spice.0"/>
    </channel>
    <graphics type="spice" autoport="no" listen="0.0.0.0" port="5269">
      <image compression="auto_glz"/>
      <jpeg compression="always"/>
      <streaming mode="all"/>
    </graphics>
    <video>
      <model heads="1" vram="65536" ram="65536" type="qxl"/>
    </video>
    <sound model='ac97'/>

    <redirdev type="spicemvc" bus="usb"/>
  </devices>
  <qemu:commandline>
    <qemu:arg value="-snapshot"/>
  </qemu:commandline>
</domain>

        """